package com.ruoyi.framework.web.service;

import java.util.List;

import com.ruoyi.project.cwsk.channel.domain.Channel;
import com.ruoyi.project.cwsk.channel.service.IChannelService;
import com.ruoyi.project.cwsk.cpgame.domain.CpGame;
import com.ruoyi.project.cwsk.cpgame.service.ICpGameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.dict.domain.DictData;
import com.ruoyi.project.system.dict.service.IDictDataService;

/**
 * RuoYi首创 html调用 thymeleaf 实现字典读取
 * 
 * @author ruoyi
 */
@Service("dict")
public class DictService
{
    @Autowired
    private IDictDataService dictDataService;
    @Autowired
    private ICpGameService cpGameService;
    @Autowired
    private IChannelService channelService;

    /**
     * 根据字典类型查询字典数据信息
     * 
     * @param dictType 字典类型
     * @return 参数键值
     */
    public List<DictData> getType(String dictType)
    {
        return dictDataService.selectDictDataByType(dictType);
    }

    /**
     * 根据字典类型和字典键值查询字典数据信息
     * 
     * @param dictType 字典类型
     * @param dictValue 字典键值
     * @return 字典标签
     */
    public String getLabel(String dictType, String dictValue)
    {
        return dictDataService.selectDictLabel(dictType, dictValue);
    }

    /**
     * 根据游戏名字查游戏列表
     *
     * @param gameType 游戏名
     * @return 参数键值
     */
    @Cacheable(cacheNames="loadGames",key = "#gameType")
    public List<CpGame> loadGames(String gameType)
    {
        CpGame cpGame = new CpGame();
        cpGame.setGameName(gameType);
        return cpGameService.loadGames(cpGame);
    }

    /**
     * 渠道商列表
     *
     * @param type
     * @return 参数键值
     */
    @Cacheable(cacheNames="loadChannels",key = "#type")
    public List<Channel> loadChannels(String type)
    {
        Channel channel = new Channel();
        return channelService.loadChannels(channel);
    }
}
